//
//	Hothot.m
//
//	Create by mafeng on 9/8/2016
//	Copyright © 2016. All rights reserved.
//	Model file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport



#import "Hothot.h"

NSString *const kHothotList = @"list";
NSString *const kHothotPagecount = @"pagecount";
NSString *const kHothotPageindex = @"pageindex";
NSString *const kHothotRowcount = @"rowcount";

@interface Hothot ()
@end
@implementation Hothot




/**
 * Instantiate the instance using the passed dictionary values to set the properties values
 */

-(instancetype)initWithDictionary:(NSDictionary *)dictionary
{
	self = [super init];
	if(dictionary[kHothotList] != nil && [dictionary[kHothotList] isKindOfClass:[NSArray class]]){
		NSArray * listDictionaries = dictionary[kHothotList];
		NSMutableArray * listItems = [NSMutableArray array];
		for(NSDictionary * listDictionary in listDictionaries){
			HotList * listItem = [[HotList alloc] initWithDictionary:listDictionary];
			[listItems addObject:listItem];
		}
		self.list = listItems;
	}
	if(![dictionary[kHothotPagecount] isKindOfClass:[NSNull class]]){
		self.pagecount = dictionary[kHothotPagecount];
	}

	if(![dictionary[kHothotPageindex] isKindOfClass:[NSNull class]]){
		self.pageindex = dictionary[kHothotPageindex];
	}

	if(![dictionary[kHothotRowcount] isKindOfClass:[NSNull class]]){
		self.rowcount = dictionary[kHothotRowcount];
	}

	return self;
}


/**
 * Returns all the available property values in the form of NSDictionary object where the key is the approperiate json key and the value is the value of the corresponding property
 */
-(NSDictionary *)toDictionary
{
	NSMutableDictionary * dictionary = [NSMutableDictionary dictionary];
	if(self.list != nil){
		NSMutableArray * dictionaryElements = [NSMutableArray array];
		for(HotList * listElement in self.list){
			[dictionaryElements addObject:[listElement toDictionary]];
		}
		dictionary[kHothotList] = dictionaryElements;
	}
	dictionary[kHothotPagecount] = self.pagecount;
	dictionary[kHothotPageindex] = self.pageindex;
	dictionary[kHothotRowcount] = self.rowcount;
	return dictionary;

}

/**
 * Implementation of NSCoding encoding method
 */
/**
 * Returns all the available property values in the form of NSDictionary object where the key is the approperiate json key and the value is the value of the corresponding property
 */
- (void)encodeWithCoder:(NSCoder *)aCoder
{
	if(self.list != nil){
		[aCoder encodeObject:self.list forKey:kHothotList];
	}
	[aCoder encodeObject:self.pagecount forKey:kHothotPagecount];	[aCoder encodeObject:self.pageindex forKey:kHothotPageindex];	[aCoder encodeObject:self.rowcount forKey:kHothotRowcount];
}

/**
 * Implementation of NSCoding initWithCoder: method
 */
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
	self = [super init];
	self.list = [aDecoder decodeObjectForKey:kHothotList];
	self.pagecount = [aDecoder decodeObjectForKey:kHothotPagecount];
	self.pageindex = [aDecoder decodeObjectForKey:kHothotPageindex];
	self.rowcount = [aDecoder decodeObjectForKey:kHothotRowcount];
	return self;

}

/**
 * Implementation of NSCopying copyWithZone: method
 */
- (instancetype)copyWithZone:(NSZone *)zone
{
	Hothot *copy = [Hothot new];

	copy.list = [self.list copyWithZone:zone];
	copy.pagecount = self.pagecount;
	copy.pageindex = self.pageindex;
	copy.rowcount = self.rowcount;

	return copy;
}
@end
